package com.example.test;

import java.util.concurrent.CountDownLatch;

/**
 * TODO: 这里要写注释的!
 */
public class VideoConference implements Runnable {
    private final CountDownLatch countDownLatch;
    public VideoConference(int number){
        countDownLatch= new CountDownLatch(number);
    }
    public void arrive(String name){
        System.out.printf("%s has arrived.\n",name);
        countDownLatch.countDown();
        System.out.printf("VideoConference waiting for %d participants\n", countDownLatch.getCount());
    }

    @Override public void run() {
        System.out.printf("VideoConference: initialization: %d participants \n",countDownLatch.getCount());
        try {
            countDownLatch.await();
            System.out.printf("VideoConference: All the participants have come.");
            System.out.println("VideoConference: Let's start...");
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
